** This file generates the summary statistics of lenders' balance sheets (Table 2)

* Load lenders' balance sheet data
use "$procdata/final_Experian.dta", clear


* Summarize variables and export to table 
eststo clear

local lender_stats *gr_w TotalEquity_ratio ShortTermDebt_ratio ///
	LongTermDebt_ratio LTfunding_ratio 
	
eststo full_sample: quietly estpost summarize `lender_stats', d
eststo full_nonbanks: qui estpost summarize `lender_stats' if (nonbank_lender == 1) , d
eststo full_banks: qui estpost summarize `lender_stats' if (nonbank_lender == 0), d

* Tabulate results
esttab full_sample full_nonbanks full_banks using "${tables}/Experian_DescriptiveStats.tex", ///
		prehead("\begin{tabular}{l*{4}{cccc}} \toprule") ///
		mgroups("All lenders" "Nonbanks" "Banks", ///
		pattern(1 1 1 ) prefix(\multicolumn{@span}{c}{) ///
		suffix(}) span erepeat(\cmidrule(lr){@span})) ///
		cells("mean(fmt(%6.2f)) sd(fmt(%8.2fc)) p50(fmt(%6.2f))") /// count(fmt(%12.0gc))
		nomtitles nonumbers label collabels("Mean" "Std. Dev." "Median") ///
		stats(N, fmt(%12.0gc)) replace ///
		prefoot("\hline") ///
		postfoot("\hline\hline \end{tabular}")   
		